<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
        <title>Document</title>
        <script>
            /* 
                获取两个日期之间相差的天数
             */
            /* 
                规定，传入日期格式
                "2000-01-01"
                "2000/01/01"
             */
            function countOfDate(d1, d2){
                var dd1 = new Date(d1);
                var dd2 = new Date(d2);

                var time1 = dd1.getTime();
                var time2 = dd2.getTime();
                var time = Math.abs(time1 - time2);
                return parseInt(time / 1000 / 3600 / 24);
            }


            // alert(countOfDate("2008-08-08", "2019-10-09"));


            /* 
                输入n，输出n天后的时间。
             */
            function afterOfDate(n){
                var d = new Date();
                var day = d.getDate();
                d.setDate(day + n);
                return d;
            }
            alert(afterOfDate(30));
        </script>
    </head>
    <body>
        
    </body>
</html>